import 'package:easy_rich_text/easy_rich_text.dart';
import 'package:flutter/material.dart';

import '../../../hj_model/video_model.dart';

class PostWordRichText extends StatelessWidget {
  final VideoModel? videoModel;
  final bool isDartStyle;

  PostWordRichText({this.videoModel, this.isDartStyle = false});

  @override
  Widget build(BuildContext context) {
    return EasyRichText(
      '${videoModel?.chosen == true ? '#精选#' : ''}${videoModel?.title ?? ''}',
      defaultStyle: TextStyle(color: Color(0x73FFFFFF), fontSize: 14),
      patternList: [
        EasyRichTextPattern(
            targetString: '#精选#',
            matchBuilder: (_, match) {
              return WidgetSpan(
                child: Container(
                  margin: EdgeInsets.only(right: 6),
                  padding: EdgeInsets.only(left: 4, right: 4, top: 1, bottom: 1),
                  decoration: BoxDecoration(
                    color: isDartStyle ? Color(0xff3476FF) : Color(0xff3476FF),
                    borderRadius: BorderRadius.all(Radius.circular(3)),
                  ),
                  child: Text(
                    (match?.input ?? '').replaceAll('#', ''),
                    style: TextStyle(
                      color: Colors.white,
                      fontSize: 12,
                      height: 1.2,
                    ),
                  ),
                ),
              );
            })
      ],
    );
  }
}
